import { MenuProps, MenuItemClicked } from 'element-plus'
import { NavigationFailure } from 'vue-router'
import { MenuOptionsType } from '../../common'

export const MenuSelectHandlerType_Name = 'MenuSelectHandlerType'
export const MenuOpenHandlerType_Name = 'MenuOpenHandlerType'
export const MenuCloseHandlerType_Name = 'MenuCloseHandlerType'
export const MenuPropsType_Name = 'MenuPropsType'

export type MenuSelectHandlerType = (
  index: string,
  indexPath: string[],
  item: MenuItemClicked | undefined,
  routerResult: Promise<void | NavigationFailure> | undefined
) => void

export type MenuOpenHandlerType = (index: string, indexPath: string[]) => void

export type MenuCloseHandlerType = (index: string, indexPath: string[]) => void

export type MenuPropsType = Partial<MenuProps> & {
  // 菜单配置
  options?: MenuOptionsType
  // 是否显示边框
  border?: boolean | string
  // 菜单激活回调函数
  selectHandler?: MenuSelectHandlerType
  // sub-menu 展开的回调函数
  openHandler?: MenuOpenHandlerType
  // sub-menu 收起的回调函数
  closeHandler?: MenuCloseHandlerType
}
